﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.Master" AutoEventWireup="true"
    CodeBehind="student.aspx.cs" Inherits="RC1.admin.student" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 111px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp1:ToolkitScriptManager>
    <h3>
        Stovna næming</h3>
    <table style="width: 100%;">
        <asp:Label ID="errorLabel" runat="server" Text="" Visible="false"></asp:Label>
        <tr>
            <td class="style1">
                T-post
            </td>
            <td>
                <asp:TextBox ID="emailTextBox" runat="server"></asp:TextBox> <span style="color:red;">*</span>
                <asp:RegularExpressionValidator runat="server" ID="rexNumber" ControlToValidate="emailTextBox"
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Vinarliga skriva eia ordiligan T-Post" ForeColor="Red"/>
            </td>
        </tr>
        <tr>
            <td class="style1">
                Loyniorð</td>
            <td>
                <asp:TextBox ID="passwordTextBox" runat="server"></asp:TextBox> <span style="color:red;">*</span>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="passwordTextBox"
                    runat="server" ErrorMessage="Koda er kravt" ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style1">
                Fornavn
            </td>
            <td>
                <asp:TextBox ID="firstnameTextBox" runat="server"></asp:TextBox> <span style="color:red;">*</span>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="firstnameTextBox"
                    runat="server" ErrorMessage="Fornavn er kravt" ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style1">
                Eftirnavn
            </td>
            <td>
                <asp:TextBox ID="lastnameTextBox" runat="server"></asp:TextBox> <span style="color:red;">*</span>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="lastnameTextBox"
                    runat="server" ErrorMessage="Eftirnavn er kravt" ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style1">
                Telefonnummar
            </td>
            <td>
                <asp:TextBox ID="phoneNumberTextBox" runat="server"></asp:TextBox>
                <asp1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1"  TargetControlID="phoneNumberTextBox" FilterType="Numbers" runat="server">
                </asp1:FilteredTextBoxExtender>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="Button2" runat="server" Text="Innset" OnClick="Button2_Click" />
                &nbsp;&nbsp;&nbsp;
                <asp:Button ID="Button1" runat="server" Text="Angra" />
            </td>
        </tr>
    </table>
    <br />
    <hr />
    <br />
    <h3>
        Yvirlit</h3>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="user_id,user_id1"
        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."
        AllowSorting="True" CellPadding="5">
        <Columns>
            <asp:BoundField DataField="user_id" HeaderText="user_id" InsertVisible="False" ReadOnly="True"
                SortExpression="user_id" Visible="False" />
            <asp:BoundField DataField="user_email" HeaderText="T-postur" 
                SortExpression="user_email" />
            <asp:BoundField DataField="user_level" HeaderText="user_level" SortExpression="user_level"
                Visible="False" />
            <asp:BoundField DataField="user_password" HeaderText="Loyniorð" 
                SortExpression="user_password" />
            <asp:BoundField DataField="user_id1" HeaderText="user_id1" ReadOnly="True" SortExpression="user_id1"
                Visible="False" />
            <asp:BoundField DataField="user_info_first_name" HeaderText="Fornavn" SortExpression="user_info_first_name" />
            <asp:BoundField DataField="user_info_last_name" HeaderText="Eftirnavn" SortExpression="user_info_last_name" />
            <asp:BoundField DataField="user_info_phone_number" HeaderText="Tlf nr" SortExpression="user_info_phone_number" />
            <asp:TemplateField HeaderText="">
                <ItemTemplate>
                    <%# getButtons((int)Eval("user_id"), (String)Eval("user_info_first_name") + " " + (String)Eval("user_info_last_name"))%>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tsu2011db4ConnectionString1 %>"
        DeleteCommand="DELETE FROM [lpuser] WHERE [user_id] = @user_id" InsertCommand="INSERT INTO [lpuser] ([user_email], [user_level], [user_password]) VALUES (@user_email, @user_level, @user_password)"
        ProviderName="<%$ ConnectionStrings:tsu2011db4ConnectionString1.ProviderName %>"
        SelectCommand="SELECT * FROM [lpuser] JOIN user_info ON lpuser.user_id = user_info.user_id WHERE ([user_level] = @user_level)"
        UpdateCommand="UPDATE [lpuser] SET [user_email] = @user_email, [user_level] = @user_level, [user_password] = @user_password WHERE [user_id] = @user_id">
        <DeleteParameters>
            <asp:Parameter Name="user_id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="user_email" Type="String" />
            <asp:Parameter Name="user_level" Type="Int32" />
            <asp:Parameter Name="user_password" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:Parameter DefaultValue="0" Name="user_level" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="user_email" Type="String" />
            <asp:Parameter Name="user_level" Type="Int32" />
            <asp:Parameter Name="user_password" Type="String" />
            <asp:Parameter Name="user_id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
